package com.tianji.learning.controller;

import com.tianji.api.dto.leanring.LearningLessonDTO;
import com.tianji.api.dto.leanring.LearningRecordFormDTO;
import com.tianji.learning.service.ILearningRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/*
 *   Description LearningRecordsController
 *   @author zhangyan
 *   @time   2024/12/7
 */
@Slf4j
@RestController("learningRecordsController")
@RequestMapping("/learning-records")
@Api(tags = "学习记录的相关接口")
public class LearningRecordsController {
    @Autowired
    private ILearningRecordService learningRecordService;

    @GetMapping("/course/{courseId}")
    @ApiOperation("根据课程id查询学习记录")
   public LearningLessonDTO queryLearningRecordByCourse(@PathVariable("courseId") Long courseId){
        return learningRecordService.queryLearningRecordByCourse(courseId);
    }


    @PostMapping
    @ApiOperation("提交学习记录")
    public void addLearningRecord(@RequestBody LearningRecordFormDTO formDTO){
        learningRecordService.addLearningRecord(formDTO);
    }
}
